#! /bin/bash
# author:xiaohe
# 用于设置yum源

yumpath="/mydir/testdir/yum.repos.d"
centos_base_path="${yumpath}/CentOS-Base.repo"
centos_vault_path="${yumpath}/CentOS-Vault.repo"
echo "开始修改yum源..."
cd ${yumpath}
cp CentOS-Base.repo ./CentOS-Base.repo.backup
cp CentOS-Vault.repo ./CentOS-Vault.repo.backup
rm -f {CentOS-Base.repo,CentOS-Vault.repo}
touch {CentOS-Base.repo,CentOS-Vault.repo}
centos_base_content="#entOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#released updates
                                                                                                 5,1           Top
#! /bin/bash
# author:xiaohe
# 用于设置yum源

yumpath="/etc/yum.repos.d"
centos_base_path="${yumpath}/CentOS-Base.repo"
centos_vault_path="${yumpath}/CentOS-Vault.repo"
echo "开始修改yum源..."
cd ${yumpath}
cp CentOS-Base.repo ./CentOS-Base.repo.backup
cp CentOS-Vault.repo ./CentOS-Vault.repo.backup
rm -f {CentOS-Base.repo,CentOS-Vault.repo}
touch {CentOS-Base.repo,CentOS-Vault.repo}
centos_base_content="#entOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#released updates
"../../setyum.sh" 127L, 3936C written                                                            
[root@localhost yum.repos.d]# clear

[root@localhost yum.repos.d]# cd ..
[root@localhost testdir]# cd ..
[root@localhost mydir]# cat setyum.sh 
#! /bin/bash
# author:xiaohe
# 用于设置yum源

yumpath="/etc/yum.repos.d"
centos_base_path="${yumpath}/CentOS-Base.repo"
centos_vault_path="${yumpath}/CentOS-Vault.repo"
echo "开始修改yum源..."
cd ${yumpath}
cp CentOS-Base.repo ./CentOS-Base.repo.backup
cp CentOS-Vault.repo ./CentOS-Vault.repo.backup
rm -f {CentOS-Base.repo,CentOS-Vault.repo}
touch {CentOS-Base.repo,CentOS-Vault.repo}
centos_base_content="#entOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#released updates
[updates]
name=CentOS-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6"
cat>${centos_base_path}<<EOF
${centos_base_content}
EOF
sleep 2
centos_vault_content="#entOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-6.10 - Base - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
 
#released updates
[updates]
name=CentOS-6.10 - Updates - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6"
cat>${centos_vault_path}<<EOF
${centos_vault_content}
EOF
sleep 2
cd /
echo "yum源修改完成!!!"